package org.zhongyin.Dao;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;

import org.zhongyin.JPA.Entity.Arxbufferwd;




public class ARXBufferWDDaoImpl {
	private static final String PERSISTENCE_UNIT_NAME = "ARXBuffer";
	private static EntityManagerFactory factory;
	private EntityManager em;
	
	
	public ARXBufferWDDaoImpl(){
		factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
		em = factory.createEntityManager();
	}
	
	public List<Arxbufferwd> getAllData(){
		Query query = em.createQuery("UPDATE Arxbufferwd a SET u.arx_1_2_24 = :arx_1_2_24, " +
				"					u.arx_2_3_24 = :arx_2_3_24," +
				"					u.arx_3_4_24 = :arx_3_4_24," +
				"					u.arx_4_5_24 = :arx_4_5_24," +
				"					u.arx_5_6_24 = :arx_5_6_24," +
				"					u.arx_6_7_24 = :arx_6_7_24," +
				"					u.arx_24_168 = :arx_24_168 where" +
				"					hour = :current_hour ");
		
		List<Arxbufferwd> result = query.getResultList();
		
		System.out.println(result.get(0).getHour());
		
		return result;
	}
	
	
	
	public static void main(String[] args) {
		ARXBufferWDDaoImpl wd = new ARXBufferWDDaoImpl();
		wd.getAllData();

	}

}
